import Vue from 'vue';
import Antd from 'ant-design-vue';
import App from './App.vue';
import router from './router';
import Vuex from 'vuex';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'ant-design-vue/dist/antd.css';
Vue.config.productionTip = false;
Vue.use(Antd);
Vue.use(ElementUI);
Vue.use(Vuex);

router.beforeEach((to,from,next) =>{
  if(to.path == '/login'){
    sessionStorage.removeItem('user');
  }
  let user = JSON.parse(sessionStorage.getItem('user'));
  if(!user && to.path != '/login'){
    next({path:'/login'});
  }else{
    next();
  }
})
new Vue({
  router,
  render: h => h(App),
}).$mount('#app');
